package com.cloudlead.utils.scheduler;

import java.io.Serializable;

import org.quartz.Trigger.TriggerState;

/**
 * 
 * 定时任务元数据
 * 
 * @author dean.lu
 * 
 * 
 */
public class JobMetadata implements Serializable {

	/**
	 * SID
	 */
	private static final long serialVersionUID = 1831958955039635571L;

	private String schedName;// 计划名称
	private String name; // 名称
	private String group; // 组名
	private TriggerState triggerState;// 触发状态
	private String jobClassName; // 任务类名
	private String cron; // CRON表达式
	private String description; // 描述

	public JobMetadata() {
		this.name = null;
		this.group = null;
		this.jobClassName = null;
		this.cron = null;
		this.description = null;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((group == null) ? 0 : group.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((schedName == null) ? 0 : schedName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		JobMetadata other = (JobMetadata) obj;
		if (group == null) {
			if (other.group != null)
				return false;
		} else if (!group.equals(other.group))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (schedName == null) {
			if (other.schedName != null)
				return false;
		} else if (!schedName.equals(other.schedName))
			return false;
		return true;
	}



	@Override
	public String toString() {
		return String
				.format("{schedName:%s, name:%s, group:%s, triggerState:%s, jobClassName:%s, cron:%s, description:%s}",
						schedName, name, group, triggerState, jobClassName,
						cron, description);
	}

	/**
	 * GET/SET
	 */

	public String getSchedName() {
		return schedName;
	}

	public void setSchedName(String schedName) {
		this.schedName = schedName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getGroup() {
		return group;
	}

	public void setGroup(String group) {
		this.group = group;
	}

	public TriggerState getTriggerState() {
		return triggerState;
	}

	public void setTriggerState(TriggerState triggerState) {
		this.triggerState = triggerState;
	}

	public String getJobClassName() {
		return jobClassName;
	}

	public void setJobClassName(String jobClassName) {
		this.jobClassName = jobClassName;
	}

	public String getCron() {
		return cron;
	}

	public void setCron(String cron) {
		this.cron = cron;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

}
